package com.azt.novel.news.controller;


import com.azt.novel.common.resp.RestResp;
import com.azt.novel.news.dto.resp.NewsInfoRespDto;
import com.azt.novel.news.service.INewsInfoService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 新闻信息 前端控制器
 * </p>
 *
 * @author azt
 * @since 2023-12-02
 */
@RestController
@RequestMapping("/api/front/news")
public class NewsInfoController {

    @Resource
    private INewsInfoService iNewsInfoService;


    /**
     * 新闻信息查询接口
     * @param newsId
     * @return
     */
    @Operation(summary = "新闻信息查询接口")
    @GetMapping("/{newsId}")
    public RestResp<NewsInfoRespDto> getNewsById(
            @Parameter(description = "新闻ID") @PathVariable("newsId")Long newsId){
        return iNewsInfoService.getNewsById(newsId);
    }

    /**
     * 最新新闻列表查询接口
     * @return
     */
    @Operation(summary = "最新新闻列表查询接口")
    @GetMapping("/latest_list")
    public RestResp<List<NewsInfoRespDto>> listLatestNews(){
        return iNewsInfoService.listLatestNews();
    }
}
